Ext.define('PJ.view.unitregistrationmanagement.Upload', {
    extend: 'AM.default.DefaultWindowForm',
    
    width: 500,
    autoHeight: true,
    
    initComponent: function(){
    	var me = this;
        this.items = [{
        	xtype: "container",
        	layout: "column",
        	items:[{
            	xtype:"filefield",
            	fieldLabel: "请选择文件",
            	margin: '5 0 0 0',
            	labelWidth: 75,
				labelAlign:'right',
            	columnWidth: .78,
            	name: "aicc",
                emptyText:"请选择文件",
                buttonText: '',
                buttonConfig: {
                    iconCls: 'updateIco'
                },
                validator: function(value){
                	var arr = value.split('.');
                	if(arr[arr.length-1] == 'xls' || arr[arr.length-1] == 'xlsx' || arr[arr.length-1] == 'pdf' || arr[arr.length-1] == 'doc' || arr[arr.length-1] == 'docx' || arr[arr.length-1] == 'rar' || arr[arr.length-1] == 'zip'){
                		return true;
                	}else {
                		return '您上传的文件格式不正确！';
                	}
                }
            }, {
                xtype: 'button',
                text: '下载模板',
    			width : 80,
    			margin: '5 0 0 2',
//            	padding: '2 0 2 0',
                columnWidth: .2,
    			listeners : {
    				click : function() {
    					var atag = Ext.get("exportResume");
    					atag.set({
    						"href": me.win.store.downUnitUrl
    					});
    					atag.dom.click();
    				}
    			}
            }, {
                xtype: 'label',
                html: '导入文件格式为.xls',
                style: 'color:red;',
                margin: '15px 0px 0px 110px',
                columnWidth: 1
            }]
        }];
        this.buttons = [{
        	text: '确定',
        	scope: this,
        	handler: function(button,event){
        		var win = button.up("window");
        		win.sub();
        	}
        },{
            text: '关闭',
            scope: this,
            handler: function(button, event){
				button.up('window').close();
            }
        }];
        this.callParent(arguments);
    },
    sub: function(){
    	var win = this;
    	var form = win.down('form');
    	var baseForm = form.getForm();
    	if (!baseForm.isValid()) {
    		return;
    	}
		win.submit({
			url: win.win.store.importUrl,
			params: {
				searchClassID: win.classId
			},
    		success: function(f, action){
    			if (action.result.success) {
//    				Ext.Msg.alert('提示', '操作成功！', function(){
//    					win.grid.getStore().load();
//        				win.close();
//    				});
//    				win.win.up('window').close();
    				if(action.result.msg){
    					if(action.result.data.length){
    						Ext.Msg.alert('提示', decodeURI(action.result.msg),function(){
        	    	            Ext.create('PJ.view.unitregistrationmanagement.CloseUserListFrame',{
        	    	    			title: "确认报名人员",
        	    	    			win: win.win,
        	    	    			classId:win.classId,
        	    	    			clickSource:win.clickSource,//点击来源
        	    	    			auditingState: win.auditingState//报名状态
        	    	    		}).show();
        					});
    					}else{
    						Ext.Msg.alert('提示', decodeURI(action.result.msg));
    					}
    				}else{
    					Ext.create('PJ.view.unitregistrationmanagement.CloseUserListFrame',{
        	    			title: "确认报名人员",
        	    			win: win.win,
        	    			classId:win.classId,
        	    			clickSource:win.clickSource,//点击来源
        	    			auditingState: win.auditingState//报名状态
        	    		}).show();
    				}
    				win.close();
    			}else{
    				Ext.Msg.alert('提示', action.result.msg, function(){
    					win.close();
    				});
    			}
    		},
    		failure: function(f, action){
    			if (action.result) {
    				Ext.Msg.alert('提示', action.result.msg, function(){
    					win.close();
    				});
    			}
    			else {
    				Ext.Msg.alert('提示', '操作失败！', function(){
    					win.close();
    				});
    			}
    		}
    	});
    }
//    ,
//    listeners: {
//    	close: function(){
//    		this.grid.store.load();
//    	}
//    }
});
